﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 影片售票系统.Yly
{
    public partial class MovieSelect : Form
    {
        string name;
        public MovieSelect()
        {
            InitializeComponent();
        }

        public MovieSelect(string name1)
        {
            InitializeComponent();
            name = name1;
        }


        private void shouye_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            MainForm mainform = new MainForm();
            this.Close();
            mainform.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
          
        }

        private void MovieSelect_Load(object sender, EventArgs e)
        {
            button1.BackColor = Color.Transparent;
            this.textBox2.Text = name;
            this.panel8.Hide();
            this.panel4.Visible = false;
            this.panel5.Visible = false;
            this.panel6.Visible = false;
            this.panel7.Visible = false;
            string sql = string.Format("select * from T_Movie where name like '%{0}%'", name);
            DataTable table = common.DBHelper.read(sql);
            if (table.Rows.Count > 0)
            {

                if (table.Rows.Count > 0)
                {
                    this.panel4.Visible = true;
                    string zx = table.Rows[0]["lujin"].ToString();
                    this.pic_1.Image = Image.FromFile(zx);
                    this.link_name1.Text = table.Rows[0]["name"].ToString();
                    this.pingf_1.Text = table.Rows[0]["pingfen"].ToString();
                    this.type_1.Text = table.Rows[0]["type"].ToString();
                    this.lab_date1.Text = table.Rows[0]["date"].ToString();
                 
                }

                if (table.Rows.Count > 1)
                {
                    this.panel5.Visible = true;
                    string zx = table.Rows[1]["lujin"].ToString();
                    this.pic_2.Image = Image.FromFile(zx);
                    this.link_name2.Text = table.Rows[1]["name"].ToString();
                    this.pingf_2.Text = table.Rows[1]["pingfen"].ToString();
                    this.type_2.Text = table.Rows[1]["type"].ToString();
                    this.lab_date2.Text = table.Rows[1]["date"].ToString();
                  
                }
                if (table.Rows.Count > 2)
                {
                    this.panel6.Visible = true;
                    string zx = table.Rows[3]["lujin"].ToString();
                    this.pic_3.Image = Image.FromFile(zx);
                    this.link_name3.Text = table.Rows[3]["name"].ToString();
                    this.pingf_3.Text = table.Rows[3]["pingfen"].ToString();
                    this.type_3.Text = table.Rows[3]["type"].ToString();
                    this.lab_date3.Text = table.Rows[3]["date"].ToString();
                    
                }
                if (table.Rows.Count > 3)
                {
                    this.panel7.Visible = true;
                    string zx = table.Rows[4]["lujin"].ToString();
                    this.pic_4.Image = Image.FromFile(zx);
                    this.link_name4.Text = table.Rows[4]["name"].ToString();
                    this.pingf_4.Text = table.Rows[4]["pingfen"].ToString();
                    this.type_4.Text = table.Rows[4]["type"].ToString();
                    this.lab_date4.Text = table.Rows[4]["date"].ToString();
                }
            }
            else
            {
                this.panel8.Visible = true;

            }
          

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void bangdan_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Top top = new Top();
            this.Close();
            top.Show();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text.Length < 1)
            {
                MessageBox.Show("请输入相关电影名");
                return;
            }
            string jk=this.textBox2.Text.Trim();
            string sql = string.Format("select * from T_Movie where Name like '%{0}%'", jk);
            DataTable table = common.DBHelper.read(sql);
            if (table.Rows.Count > 0)
            {

                if (table.Rows.Count > 0)
                {
                    this.panel4.Visible = true;
                    string zx = table.Rows[0]["lujin"].ToString();
                    this.pic_1.Image = Image.FromFile(zx);
                    this.link_name1.Text = table.Rows[0]["name"].ToString();
                    this.pingf_1.Text = table.Rows[0]["pingfen"].ToString();
                    this.type_1.Text = table.Rows[0]["type"].ToString();
                    this.lab_date1.Text = table.Rows[0]["date"].ToString();
                    this.panel5.Visible = false;
                    this.panel6.Visible = false;
                    this.panel7.Visible = false;

                }

                if (table.Rows.Count > 1)
                {
                    this.panel5.Visible = true;
                    string zx = table.Rows[1]["lujin"].ToString();
                    this.pic_2.Image = Image.FromFile(zx);
                    this.link_name2.Text = table.Rows[1]["name"].ToString();
                    this.pingf_2.Text = table.Rows[1]["pingfen"].ToString();
                    this.type_2.Text = table.Rows[1]["type"].ToString();
                    this.lab_date2.Text = table.Rows[1]["date"].ToString();
                  
                    this.panel6.Visible = false;
                    this.panel7.Visible = false;
                }
                if (table.Rows.Count > 2)
                {
                    this.panel6.Visible = true;
                    string zx = table.Rows[3]["lujin"].ToString();
                    this.pic_3.Image = Image.FromFile(zx);
                    this.link_name3.Text = table.Rows[3]["name"].ToString();
                    this.pingf_3.Text = table.Rows[3]["pingfen"].ToString();
                    this.type_3.Text = table.Rows[3]["type"].ToString();
                    this.lab_date3.Text = table.Rows[3]["date"].ToString();
                   
                    this.panel7.Visible = false;
                }
                if (table.Rows.Count > 3)
                {
                    this.panel7.Visible = true;
                    string zx = table.Rows[4]["lujin"].ToString();
                    this.pic_4.Image = Image.FromFile(zx);
                    this.link_name4.Text = table.Rows[4]["name"].ToString();
                    this.pingf_4.Text = table.Rows[4]["pingfen"].ToString();
                    this.type_4.Text = table.Rows[4]["type"].ToString();
                    this.lab_date4.Text = table.Rows[4]["date"].ToString();
                }
            }
            else
            {
                this.panel4.Visible = false;
                this.panel5.Visible = false;
                this.panel6.Visible = false;
                this.panel7.Visible = false;
                this.panel8.Visible = true;

            }
            
        }

        private void link_name1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string name = this.link_name1.Text.Trim();
            Movie movie = new Movie(name);
            this.Close();
            movie.Show();
            
        }

        private void link_name2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string name = this.link_name2.Text.Trim();
            Movie movie = new Movie(name);
            this.Close();
            movie.Show();
        }

        private void link_name4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string name = this.link_name3.Text.Trim();
            Movie movie = new Movie(name);
            this.Close();
            movie.Show();
        }

        private void link_name3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string name = this.link_name4.Text.Trim();
            Movie movie = new Movie(name);
            this.Close();
            movie.Show();
        }
    }
}
